Skip to content

Limit backend messages length #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2023

Conversation

petuhovskiy
Copy link
Member

No description provided.

@petuhovskiy petuhovskiy marked this pull request as ready for review May 22, 2023 16:58
@petuhovskiy petuhovskiy changed the base branch from sk/query_raw_txt to neon May 22, 2023 16:59
@kelvich
Copy link

kelvich commented May 22, 2023

LGTM. Can you please write a test with some abundantly big row and check that this error will fire early on? rust-postgres has tests that just run against postgres working on 5433 port

@petuhovskiy petuhovskiy force-pushed the ap/limit-pgproto-msgsize branch from 49a6430 to 5936b58 Compare May 22, 2023 18:01
@petuhovskiy
Copy link
Member Author

The test produces panic somewhere in rust-postgres internally, but the caller receives only error about the closed connection. Looks good enough.

Tests are passing, I'm merging this back to #14

Stacktrace
thread 'limit_max_backend_message_size' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Io, cause: Some(Custom { kind: InvalidInput, error: "message too large" }) }', tokio-postgres/tests/test/main.rs:67:43
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:64:14
   2: core::result::unwrap_failed
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/result.rs:1790:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/result.rs:1112:23
   4: test::connect::{{closure}}::{{closure}}
             at ./tests/test/main.rs:67:41
   5: <T as futures_util::fns::FnOnce1<A>>::call_once
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.28/src/fns.rs:15:9
   6: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.28/src/future/future/map.rs:57:73
   7: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.28/src/lib.rs:91:13
   8: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/task/core.rs:223:17
   9: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/loom/std/unsafe_cell.rs:14:9
  10: tokio::runtime::task::core::Core<T,S>::poll
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/task/core.rs:212:13
  11: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/task/harness.rs:476:19
  12: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panic/unwind_safe.rs:271:9
  13: std::panicking::try::do_call
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:483:40
  14: __rust_try
  15: std::panicking::try
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:447:19
  16: std::panic::catch_unwind
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panic.rs:140:14
  17: tokio::runtime::task::harness::poll_future
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/task/harness.rs:464:18
  18: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/task/harness.rs:198:27
  19: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/task/harness.rs:152:15
  20: tokio::runtime::task::raw::poll
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/task/raw.rs:255:5
  21: tokio::runtime::task::raw::RawTask::poll
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/task/raw.rs:200:18
  22: tokio::runtime::task::LocalNotified<S>::run
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/task/mod.rs:394:9
  23: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/scheduler/current_thread.rs:584:25
  24: tokio::runtime::coop::with_budget
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/coop.rs:107:5
  25: tokio::runtime::coop::budget
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/coop.rs:73:5
  26: tokio::runtime::scheduler::current_thread::Context::run_task::{{closure}}
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/scheduler/current_thread.rs:285:29
  27: tokio::runtime::scheduler::current_thread::Context::enter
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/scheduler/current_thread.rs:350:19
  28: tokio::runtime::scheduler::current_thread::Context::run_task
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/scheduler/current_thread.rs:285:9
  29: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/scheduler/current_thread.rs:583:34
  30: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/scheduler/current_thread.rs:615:57
  31: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/macros/scoped_tls.rs:61:9
  32: tokio::runtime::scheduler::current_thread::CoreGuard::enter
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/scheduler/current_thread.rs:615:27
  33: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/scheduler/current_thread.rs:530:19
  34: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/scheduler/current_thread.rs:154:24
  35: tokio::runtime::runtime::Runtime::block_on
             at /home/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.28.0/src/runtime/runtime.rs:302:47
  36: test::limit_max_backend_message_size
             at ./tests/test/main.rs:305:5
  37: test::limit_max_backend_message_size::{{closure}}
             at ./tests/test/main.rs:284:43
  38: core::ops::function::FnOnce::call_once
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/ops/function.rs:250:5
  39: core::ops::function::FnOnce::call_once
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Error `connection closed` is returned to the caller.

@petuhovskiy petuhovskiy changed the base branch from neon to sk/query_raw_txt May 22, 2023 18:08
@petuhovskiy petuhovskiy merged commit 2c1ad15 into sk/query_raw_txt May 22, 2023
@petuhovskiy petuhovskiy deleted the ap/limit-pgproto-msgsize branch May 22, 2023 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants